import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

wine = pd.read_csv("gray.csv")
wine.head()

import pandas as pd
import numpy as np

wine=np.array(wine)

for i in range(4): # 对每列标准化
    col=wine[:,i]
    col=(col-col.mean())/col.std()
    wine[:,i]=col

best=wine[8,:]

for i in range(9):
    wine[i,:]-=best
wine=np.abs(wine)

# 算minmin
min1=[]
max1=[]
for i in range(4):
    col = wine[:, i]
    min1.append(col.min())
    max1.append(col.max())
minmin=np.array(min1).min()
maxmax=np.array(max1).max()

def f(x):
    fenzi=minmin+0.5*maxmax
    fenmu=x+0.5*maxmax
    return fenzi/fenmu

for i in range(4):
    for j in range(9):
        wine[j,i]=f(wine[j,i])

print(wine)

result=[]
for j in range(9):
    row=wine[j,:]
    result.append(row.mean())

print(result)